package com.luozongyao.serviceStatistics.controller;


import com.luozongyao.commonutils.R;
import com.luozongyao.serviceStatistics.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-08-29
 */
@RestController
@RequestMapping("/serviceStatistics/statistics-daily")
@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService dailyService;
    //统计某一天的注册人数 在service实现类调用UcenterMemberClient
    @PostMapping("statisticsRegisterCount/{day}")
    public R statisticsRegisterCount(@PathVariable String day){
        dailyService.statisticsRegisterCount(day);
        return R.ok();
    }

    //图表显示，返回两部分数据，日期json数组，数量json数组
    @GetMapping("show-chart/{type}/{begin}/{end}")
    public R showChart(@PathVariable String type,@PathVariable String begin,@PathVariable String end){
        Map<String, Object> map = dailyService.getChartData(type,begin,end);
        return R.ok().data(map);
    }



}

